#ifndef Game_h
#define Game_h

#include <windows.h>
#include <d3d9.h>

#include "Keyboard.h"

class Game
{

protected:
	bool game_active;
	LPDIRECT3D9 d3d; 
	LPDIRECT3DDEVICE9 d3ddv;
	LPDIRECT3DSURFACE9 BackBuffer;
	
	

	DWORD DeltaTime;		// Time between the last frame and current frame 
	int FrameRate; 

	int Depth;
	int done;

	D3DFORMAT BackBufferFormat;

	HINSTANCE hInstance;	
	HWND hWnd;				

	static LRESULT CALLBACK _WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

	void InitWindow();
	void InitDirectX();
	//void InitKeyboard();

	// Render a single frame
	void RenderAndUpdate();

	void ProcessKeyBoard();

	// Place holder for sub classes
	virtual void InitGameWorld();
	virtual void RenderFrame(LPDIRECT3DDEVICE9 d3ddv);
	virtual void LoadResources(LPDIRECT3DDEVICE9 d3ddv);
	virtual void ProcessInput(LPDIRECT3DDEVICE9 d3ddv);
	virtual void Update(int Delta);

	virtual void OnKeyDown(int KeyCode);
	virtual void OnKeyUp(int KeyCode);

public:
	LPDIRECT3D9 GetDirectX();
	LPDIRECT3DDEVICE9 GetDevice();
	LPDIRECT3DSURFACE9 GetBackBuffer();
	static LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

	int GetScreenWidth();
	int GetScreenHeight();
	int GetDepth();

	Game(HINSTANCE hInstance,int FrameRate);
	~Game();
	void Init();
	void Run();
};
#endif